#!/bin/sh

DAEMON_HOME=`pwd`
LOG_DIR="${DAEMON_HOME}/log"
BIN_DIR="${DAEMON_HOME}"
BIN_NAME="daemon_gis_useraddr"
RECEIVER="p_yuechen"

DATE=`date "+[%Y-%m-%d %H:%M:%S]"`
num=`ps aux | grep daemon_gis_useraddr | grep -v grep | grep -v tail |grep -v vim | grep -v vi | wc -l`

if [ $num -lt 1 ] ; then
  echo "${DATE} ${BIN_NAME} restarted." >> ${LOG_DIR}/restart.log
  ${BIN_DIR}/daemon_cntl.sh restart
  /bin/MC-CA-suse32 $RECEIVER 1 'Daemon重启告警' "${BIN_NAME} 进程重启." >/dev/null 2>&1
else
  echo ${DATE} " ${BIN_NAME} is running. process num: $num." >> ${LOG_DIR}/restart.log
fi
